Java length() method

    length() method

    This method will provide you with the string length. It will return the total character count within the provided string.

    Method implementation-

    public int length() {  
    
          return value.length;  
      }  

    Syntax-

    public int length()  

    Example-

    public class Simple{  
        public static void main(String[] args) {      
            String s1="welcome to Java";
            String s2="Java";
            System.out.println(s1.length());    
            System.out.println(s2.length());     
        }
    }  

    Output-

    Java Length Method